home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / attclk2.arc / TIMEDISP.C < prev    next >
C/C++ Source or Header  |  1986-01-09  |  745b  |  35 lines

  1. /* :ts=8
  2.  *
  3.  *    timedisp()
  4.  *
  5.  * Displays supplied string with date/time found in buf
  6.  * structure.  Displays as follows:
  7.  *
  8.  *    timedisp("Sample string");
  9.  *
  10.  *    Sample string Tue 7-Jan-86 22:12:53.11
  11.  *
  12.  */
  13.  
  14. #include "setdate.h"
  15. extern    struct tm buf;
  16.  
  17.     /* table of day strings */
  18. char    days[7][4] = {
  19.         "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  20. };
  21.     /* table of month strings */
  22. char    months[12][4] = {
  23.         "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  24.         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
  25. };
  26.  
  27. timedisp(string)
  28. char    *string;
  29. {
  30.     printf("%s%s %d-%s-%d %d:%02d:%02d.%02d", string,
  31.         days[buf.tm_wday],
  32.         buf.tm_mday, months[buf.tm_mon], buf.tm_year + 1900,
  33.         buf.tm_hour, buf.tm_min, buf.tm_sec, buf.tm_hsec);
  34. }
  35.